package cn.pacerx.running.wx.dto;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.List;
import java.util.Set;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

import cn.pacerx.running.db.enums.ActivityStatusEnum;
import cn.pacerx.running.db.enums.ActivityTypeEnum;
import cn.pacerx.running.db.enums.GroupTypeEnum;
import cn.pacerx.running.db.enums.UserActivityStatusEnum;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@Data
@ApiModel("活动实体")
public class ActivityDto {
    @ApiModelProperty("活动id")
    private Long id;

    @NotBlank
    @ApiModelProperty("名称")
    private String title;

    @ApiModelProperty("活动类型")
    private ActivityTypeEnum type;

    @ApiModelProperty("封面图片地址")
    private String coverUrl;

    @ApiModelProperty("所属类型")
    private GroupTypeEnum groupType;

    @ApiModelProperty("标签")
    private Set<String> tag;

    @NotNull
    @ApiModelProperty("开始日期")
    private LocalDate startDate;

    @NotNull
    @ApiModelProperty("结束日期")
    private LocalDate endDate;

    @ApiModelProperty("地址")
    private String address;

    @ApiModelProperty("经度")
    private BigDecimal longitude;

    @ApiModelProperty("维度")
    private BigDecimal latitude;

    @ApiModelProperty("参加人次数")
    private Integer personNum;

    @ApiModelProperty("最低配速")
    private BigDecimal minSpeed;

    @ApiModelProperty("最高配速")
    private BigDecimal maxSpeed;

    @ApiModelProperty("距离")
    private BigDecimal distance;

    @ApiModelProperty("额外服务类型")
    private Set<String> extraService;

    @ApiModelProperty("活动详情")
    private String detail;

    @ApiModelProperty("状态")
    private ActivityStatusEnum status;

    @JsonIgnore
    @ApiModelProperty("用户参加状态")
    private UserActivityStatusEnum joinedStatus;

    @ApiModelProperty("创建人id")
    private Long userId;

    @ApiModelProperty("创建人名称")
    private String userName;

    @ApiModelProperty("历史参与人列表")
    private List<UserActivityDto> joinedUsers;

    @ApiModelProperty("备注")
    private String remark;

    @ApiModelProperty("界面显示状态")
    public String getDisplayStatus() {
        if (joinedStatus != null && status == ActivityStatusEnum.PENDING) {
            return joinedStatus.name();
        }
        return status.name();
    }
}
